/**
 * 公告列表
 */
Ext.define('DragonApp.view.notice.Grid', {
    extend: 'DragonApp.view.foundation.Grid',
    alias: ['widget.noticegrid'],

    requires: [
        'Ext.overrides.locale.zh_CN.Filters',
        'DragonApp.store.JsonPNotice',
        'DragonApp.view.notice.Bar',
        'Ext.grid.filters.Filters'
    ],
    selModel: {
        selType: 'checkboxmodel'
    },

    controller: 'notice',

    dockedItems: [{
        xtype: 'notice-bar',
        dock: 'top'
    }],

    columns: [
        { text: '序号', xtype: 'rownumberer', width: 70, align: 'center' },
        { text: '序号', dataIndex: 'id', align: 'center', hideable: false, hidden: true },
        { text: '开始时间', dataIndex: 'begintime', width: 145, hideable: false, align: 'center' },
        { text: '截止时间', dataIndex: 'endtime', width: 145, hideable: false, align: 'center' },
        { text: '适用渠道', dataIndex: 'channel', align: 'center', hideable: false, renderer: 'channelRender' },
        {
            text: '标题',
            dataIndex: 'title',
            align: 'left',
            hideable: false,
            renderer: 'attrRender',
            flex: 1,
            filter: {
                type: 'string',
                itemDefaults: {
                    emptyText: '请输入筛选关键字...'
                }
            }
        }, {
            text: '正文',
            dataIndex: 'content',
            align: 'left',
            flex: 1,
            renderer: 'attrRender',
            hideable: false,
            hidden: true
        }, {
            text: '标签',
            dataIndex: 'tag',
            width: 70,
            hideable: false,
            align: 'center',
            filter: {
                type: 'list',
                options: ['限定', '预告', '奖励', '火爆']
            }
        },
        {
            text: '图像',
            dataIndex: 'pictures',
            align: 'center',
            hidden: true,
            hideable: false
        },
        {
            text: '类型',
            dataIndex: 'type',
            width: 70,
            hideable: false,
            align: 'center',
            filter: {
                type: 'list',
                options: ['文字', '图像']
            }
        },
        {
            text: '状态',
            dataIndex: 'status',
            width: 70,
            hideable: false,
            align: 'center',
            renderer: 'statusRender'
        },
        {
            text: '创建时间',
            dataIndex: 'create_time',
            width: 145,
            hideable: false,
            align: 'center'
        }
    ],
    store: {
        type: 'jsonPNoticeStore',
        storeId : 'jsonPNoticeStore'
    },

    plugins: [{
        ptype: 'gridfilters'
    }, {
        ptype: 'rowexpander',
        rowBodyTpl: new Ext.XTemplate(
            '<h3>{title}</h3>',
            '<p>{preview}</p>',
            '<tpl for="pics">',
            '<div><a href="{.}" target="_blank"><img src="{.}"  alt="公告图像" width="700" /></a></div>',
            '</tpl>'
        )
    }]
});